﻿using Microsoft.AspNetCore.Mvc;
using NewLife.Serialization;

namespace newlife.core.api.Controllers
{
    /// <summary>
    /// JSON 操作
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class JsonController : ControllerBase
    {
        [HttpPost]
        public IActionResult Serialization(string name)
        {
            return Ok(new { Id = 1, Name = name }.ToJson());
        }

        [HttpPost]
        public IActionResult Deserialization(string json)
        {
            //return Ok(json.ToJsonEntity<dynamic>());
            return Ok(json.DecodeJson());
        }
    }
}
